package com.lj.controller;

import com.lj.pojo.Pstaff;
import com.lj.service.PstaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/pStaff")
public class PstaffAction {
    @Autowired
    PstaffService pstaffService;
    @RequestMapping("/select")
    public String select(String id, HttpServletRequest request){
        Pstaff pstaff= pstaffService.select(id);
        System.out.println(pstaff==null);
        request.setAttribute("pStaff",pstaff);
        return "staff/pStaffView";
    }
    @RequestMapping("/update")
    public String update(String staffPassword, String staffName, Byte staffAge, String staffSex, String staffPhone, String staffId, RedirectAttributes attributes){
        int nums= pstaffService.update(staffPassword,staffName,staffAge,staffSex,staffPhone,staffId);
        attributes.addAttribute("id",staffId);
        return "redirect:/pStaff/select.action";
    }
}
